home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload Trio 2 / Shareware Overload Trio Volume 2 (Chestnut CD-ROM).ISO / dir24 / aprs308.zip / MAPFIX.BAS < prev    next >
BASIC Source File  |  1994-01-03  |  43KB  |  936 lines

  1. REM MAPFIX.bas PROGRAM.  SEE EXPLAINATION BELOW
  2. REM
  3. Ver$ = "3.08"
  4. MaxNumMAPS = 99' Current maximum number of maps loaded by APRS
  5. MaxNumPoints = 1000
  6. MaxNumLABELS = 99
  7. GOTO Begin
  8.  
  9. Info: COLOR 15, 1: CLS
  10.    PRINT " MAPFIX.bas VERSION "; Ver$; " PROGRAM FOR FIXING APRS MAPS": PRINT
  11.    PRINT " 2.10 allowed you to add, move and delete points.  3.01 added new Features"
  12.    PRINT " 3.05 allowed you to KILL features and TRIM all points outside a boundary."
  13.    PRINT " 3.07 added ALT-G to overlay GPS track history files for map drawing."
  14.    PRINT " 3.07P adds W7KKE's CALCOMP digitizer code for drawing directly from charts."
  15.    PRINT " 3.08 fixed bug in assigning filenames on Saving (new map saved to TK.HST file!)"
  16.    PRINT
  17.    PRINT " CAUTION, THIS PROGRAM IS NOT PERFECT... KEEP BACKUPS!  Do a little at a time!"
  18.    PRINT
  19.    PRINT " The original purpose of this program was to simply display new maps so you"
  20.    PRINT " could alternatively EDIT the map file and use MAPFIX to look at it and measure"
  21.    PRINT " locations and points.  Operating in the full QBasic environment, you could "
  22.    PRINT " keep both the MAPFIX program and the MAP file online simultanously and switch"
  23.    PRINT " back and forth.  Without QB, you must alternatively use EDIT and QBasic."
  24.    PRINT
  25.    PRINT " MAPFIX uses two cursors.  The normal yellow APRS cursor, and a White MapPoint"
  26.    PRINT " which will be the next point to be processed.  ALT Keys allow you to MOVE the"
  27.    PRINT " MapPoint to the cursor, ADD a new point at the cursor, or DELETE the MapPoint."
  28.    PRINT " MAPFIX.bas shows you Deg/Min, Decimal, and APRS values of the cursor position."
  29.    PRINT
  30.    PRINT " ALSO NOTE THAT THE LIMITS IN APRS ARE 1000 POINTS, 99 FEATURES, and 99 LABELS!"
  31.    PRINT " If you need more points, features or labels, begin another map.";
  32.    LOCATE 25, 1: PRINT " HIT ANY KEY to continue...";
  33.    GOSUB GetChar: BEEP
  34.   
  35. Info2:   COLOR 15, 8: CLS
  36.    PRINT " PAGE 2 INSTRUCTIONS:  More about new features in version "; Ver$
  37.    PRINT
  38.    PRINT " With this new MAPFIX.bas, you can not only modify features by moving, adding"
  39.    PRINT " or deleting POINTS, but you can now add and kill FEATURES too, ie: roads,"
  40.    PRINT " rivers, borders, etc, from within the program.  In addition to the new KILL"
  41.    PRINT " and TRIM commands, the G key will move the cursor (GOTO) to the MapPoint,"
  42.    PRINT " and the F key will FIND the MapPoint nearest the cursor location.  If the"
  43.    PRINT " MapPointer and FeatureName get out of sequence, the RESET command may fix"
  44.    PRINT " them, but you should save the file immediately and check it with an editor."
  45.    PRINT
  46.    PRINT " I find the capability to delete points very useful when making larger area"
  47.    PRINT " maps from several smaller detail maps.  First, I run MAPCNVRT.bas to convert"
  48.    PRINT " all of the smaller maps to new temporary files with the new origin of the new"
  49.    PRINT " larger map.  Then I use the KILL command in MAPFIX to eliminate all minor "
  50.    PRINT " roads, features and labels and then the DELETE POINT command to remove all"
  51.    PRINT " inconsequential minor points from the roads that will not be needed"
  52.    PRINT " at the larger scale.  Then I use the editor to combine all of the points and"
  53.    PRINT " labels into the new file."
  54.    PRINT
  55.    PRINT " A new MAPLIST command shows your MAPLIST.map file; and the OTHER MAPS command"
  56.    PRINT " shows all MAP borders so you can see how your new map fits in.  You may use F3"
  57.    PRINT " and F4 keys to select smaller or larger map borders to draw."
  58.    PRINT
  59.    LOCATE 25, 1: PRINT " HIT ANY KEY to continue...";
  60.    GOSUB GetChar: BEEP
  61.   
  62. Info3:   COLOR 15, 3: CLS
  63.    PRINT " PAGE 3 INSTRUCTIONS:  Using GPS Track History Files to draw maps!"
  64.    PRINT
  65.    PRINT " To aid in creating accurate maps, W7KKE in California added routines to MAPFIX"
  66.    PRINT " so that you can overlay a Track History file onto the map you are constructing."
  67.    PRINT " This is an excellent tool for correcting your maps to real GPS data."
  68.    PRINT ""
  69.    PRINT " After you have loaded your map, type alt-G (GPS Track History') and enter the"
  70.    PRINT " history filename.  This will overlay the track history file.  You may then"
  71.    PRINT " use the normal MAPFIX.bas routines to move map segments and add so that the"
  72.    PRINT " map will agree with the GPS data contained in the track history file.  This"
  73.    PRINT " is especially useful with the history files saved by a laptop during mobile"
  74.    PRINT " GPS operations."
  75.    PRINT
  76.    PRINT " CAUTION:  Since GPS data is only accurate to 100 yards due to the effects of"
  77.    PRINT " Selective Availability, I would avoid using GPS data explicitely below about"
  78.    PRINT " the 2 mile range.  For this reason, I make the size of the GPS positions "
  79.    PRINT " expand below the 2 mile range to roughly approximate the size of the 100 yard"
  80.    PRINT " error circle."
  81.    PRINT
  82.    Display$ = "UNKnown"
  83.    RETURN
  84.  
  85. GetChar: a$ = "": DO UNTIL a$ <> "": a$ = INKEY$: LOOP: RETURN
  86.  
  87. Begin: GOSUB Info:
  88.    PRINT " HIT ANY KEY to proceed onto the HELP screen...";
  89.    GOSUB GetChar
  90.  
  91.    DIM x%(2 * MaxNumPoints), y%(2 * MaxNumPoints)
  92.    REM MAP coordinates               **** THESE ARE BIGGER THAN APRS ***
  93.    DIM LN$(150) ' (no limit in APRS)  **** SO YOU CAN MANIPULATE BIG MAPS
  94.    nn = 2 * MaxNumLABELS
  95.    DIM ML$(nn), MLa(nn), MLo(nn), MLr(nn) 'Map Labels, lengths and coordinates
  96.    nn = 2 * MaxNumMAPS
  97.    DIM MapName$(nn), LATcen(nn), LONcen(nn), MapMax(nn), Comment$(nn)
  98.    RdsOn = -1: Labls = -1: Tags = -1: KP = 1: Changed = 0: MapSize = 256
  99.    
  100.    DIM HLAT(3000), HLONG(3000)'For lat/longs from big GPS history files
  101.  
  102. INIT: ON ERROR GOTO ErrorTrap
  103.    ScrnType$ = "EGA": Ycen = 200: Yfactr = 1: YfacTXT = 350 / 350: SCREEN 9
  104.    IF ScrnType$ = "EGA" THEN COLOR 15, 0
  105.    REM ScrnType$ = "CGA": Yfactr=200/400:Ycen = 200*Yfactr: SCREEN 2
  106.   
  107. Display$ = "HELP": GOSUB HELP: GOSUB LoadMap
  108. REM ON ERROR GOTO 0
  109.  
  110. Main: GOSUB DrwMPaCur
  111.   DO
  112. GoAgain:
  113.     IF Digitizer THEN
  114.          IF LOC(1) > 9 THEN
  115.             GOSUB GetXY: GOSUB Cursor
  116.             IF Btn <> 3 THEN GOSUB AddPoint
  117.          END IF
  118.     END IF
  119.     a$ = INKEY$
  120.     IF a$ <> "" THEN
  121.         a$ = UCASE$(a$): Key$ = a$
  122.         IF a$ = "S" THEN GOSUB labels
  123.         IF a$ = "L" THEN Labls = NOT Labls
  124.         IF a$ = "T" THEN Tags = NOT Tags
  125.         IF a$ = "F" THEN GOSUB FindPoint
  126.         IF a$ = "G" THEN GOSUB CurToPoint: GOSUB CurDrwMap
  127.         IF a$ = "H" THEN
  128.            IF Display$ <> "HELP" THEN
  129.               GOSUB HELP
  130.            ELSE GOSUB Info
  131.               LOCATE 25, 1: PRINT " H for HELP or SPACE BAR for map..."; : a$ = ""
  132.            END IF
  133.         END IF
  134.         IF a$ = "D" THEN GOSUB MapDIR
  135.         IF a$ = "M" THEN GOSUB ListMAPlist
  136.         IF a$ = "O" THEN GOSUB DrwAndShow
  137.         IF a$ = "N" THEN GOSUB NextLine: GOSUB Cursor
  138.         IF a$ = "P" THEN GOSUB Previous: GOSUB Cursor
  139.         IF a$ = "Q" THEN GOSUB QUIT
  140.         IF a$ = "R" THEN Z = 2: LNptr = 1
  141.         IF a$ = " " THEN Display$ = "MAP": GOSUB DrwMPaCur
  142.         IF a$ = "+" THEN Z = Z + 1: GOSUB MapPoint ' moves to next map point
  143.         IF a$ = "-" THEN Z = Z - 1: GOSUB MapPoint ' moves backwards
  144.        
  145.         B$ = "": IF LEN(a$) = 2 THEN B$ = RIGHT$(a$, 1): REM process arrow & special keys
  146.         IF B$ = "I" THEN RS = RS * 2: GOSUB CurDrwMap: REM change scale
  147.         IF B$ = "Q" THEN RS = RS / 2: GOSUB CurDrwMap
  148.         IF B$ = CHR$(132) THEN RS = RS * 8: GOSUB CurDrwMap: REM change scale by factor of 4
  149.         IF B$ = "V" THEN RS = RS / 8: GOSUB CurDrwMap
  150.         IF B$ = "G" THEN GOSUB CurDrwMap 'Home key
  151.         IF a$ = "7" THEN CDX = LONo: CDY = LATo: GOSUB DrwMPaCur 'ShiftHOME
  152.         IF B$ = "O" THEN CDX = LONcen: CDY = LATcen: GOSUB DrwMPaCur 'End Key
  153.         IF B$ = "M" THEN CPX = CPX - 4 / (Sfac): GOSUB Cursor
  154.         IF B$ = "K" THEN CPX = CPX + 4 / (Sfac): GOSUB Cursor
  155.         IF B$ = "H" THEN CPY = CPY + 4 / (Sfac): GOSUB Cursor
  156.         IF B$ = "P" THEN CPY = CPY - 4 / (Sfac): GOSUB Cursor
  157.         REM Here are the special MapFIx routines
  158.         IF B$ = CHR$(30) THEN GOSUB AddPoint               'alt-ADD point
  159.         IF B$ = CHR$(48) AND Digitizer THEN GOSUB NewFeature'alt-BEGIN
  160.         IF B$ = CHR$(34) THEN GOSUB LoadHst                'alt-GPS hstry file
  161.         IF B$ = CHR$(50) THEN GOSUB MakePT: GOSUB DrawMap  'alt-MOVE point to cursor
  162.         IF B$ = CHR$(32) THEN GOSUB DelPT: GOSUB DrawMap   'alt-DELete point
  163.         IF B$ = CHR$(38) THEN GOSUB AddLabel               'alt-ADD LABEL
  164.         IF B$ = CHR$(46) THEN GOSUB NewCenter              'alt-CENTER
  165.         IF B$ = CHR$(37) THEN GOSUB KillF                  'alt-KILL Feature
  166.         IF B$ = CHR$(19) THEN GOSUB MapRange               'alt-RANGE
  167.         IF B$ = CHR$(20) THEN GOSUB TRIM                   'alt-TRIM
  168.         IF B$ = CHR$(49) THEN GOSUB NewFeature             'alt-NEW Feature
  169.         IF B$ = CHR$(24) THEN GOSUB DigiInit: GOSUB DrawMap'alt-OPEN dgtzr COM
  170.         IF B$ = CHR$(61) THEN                              'F3 for smaller Maps
  171.            MapSize = MapSize / 2: IF MapSize < 1 THEN MapSize = 1
  172.            GOSUB ShowMaps
  173.            END IF
  174.         IF B$ = CHR$(62) THEN                              'F4 for larger Maps
  175.            MapSize = MapSize * 2: IF MapSize > 1000 THEN MapSize = 1000
  176.            GOSUB DrwAndShow
  177.         END IF
  178.         IF a$ = CHR$(19) THEN GOSUB SaveMap
  179.            
  180.         IF a$ = "6" THEN CPX = CPX - 20 / (Sfac): GOSUB Cursor'SHIFT Cursor by 4
  181.         IF a$ = "4" THEN CPX = CPX + 20 / (Sfac): GOSUB Cursor
  182.         IF a$ = "8" THEN CPY = CPY + 20 / (Sfac): GOSUB Cursor
  183.         IF a$ = "2" THEN CPY = CPY - 20 / (Sfac): GOSUB Cursor
  184.         
  185.     END IF
  186.   LOOP
  187.   SYSTEM 'you should never get here
  188.  
  189. QUIT: a$ = "Y"
  190.       IF Changed THEN
  191.          GOSUB BoxLine23
  192.          PRINT "**** MAP HAS BEEN MODIFIED"; Changed; "TIMES BUT NOT SAVED!!!  SAVE NOW? (Y)";
  193.          INPUT a$
  194.       IF UCASE$(a$) <> "N" THEN GOSUB SaveMap
  195.       END IF
  196.       SYSTEM
  197.  
  198. TRIM: GOSUB BoxLine23
  199.       CLS : PRINT "TRIM ALL POINTS AND LABELS OUTSIDE OF MAPRANGE"
  200.       PRINT
  201.       PRINT "This command will remove all points and labels that are outside of the white"
  202.       PRINT "map border.  You can change the location of this map border by using"
  203.       PRINT "the CENTER command (alt-C) and by changing the RANGE using alt-R."
  204.       PRINT : PRINT
  205.       PRINT "No map feature will be completely eliminated..."
  206.       PRINT
  207.       PRINT "The first and last point of any FEATURE will be retained, so the"
  208.       PRINT "result will be long single lines for all FEATURES outside the map border."
  209.       PRINT "Use the KILL FEATURE (alt-K) to eliminate those lines and use the MOVE"
  210.       PRINT "command (alt-M) to move any far away points closer to the border."
  211.       PRINT : PRINT
  212.       PRINT "You might consider stopping now and doing a SAVE (ctrl-S) before proceeding."
  213.       PRINT
  214.       PRINT "ALSO, THIS DOES NOT WORK FOR POINTS WITH NEGATIVE VALUES!  Be sure  your"
  215.       PRINT "selected area is below and to right of ORIGIN.  If not, run MAPCNVRT.bas."
  216.       PRINT : PRINT
  217.       INPUT "Are you ready to proceed? (Y/N) (N)"; a$
  218.       IF UCASE$(a$) <> "Y" THEN GOTO DrawMap
  219.       C = 0: PRINT : PRINT "Processing...";
  220.       REM dx and dy are num pix of center of map
  221.       REM bx and by are borders of map based on MapRng
  222.       by = ppdV * MapRng / 60
  223.       bx = by / Lfac
  224.       FOR Z = 1 TO nmp - 4
  225.          IF x%(Z) = 0 THEN Z = Z + 2
  226.          IF x%(Z) > dx + bx OR y%(Z) > dy + by THEN bad = 1 ELSE bad = 0
  227.          IF x%(Z) < dx - bx OR y%(Z) < dy - by THEN bad = 1
  228.          IF bad AND x%(Z - 1) <> 0 AND x%(Z + 1) <> 0 THEN
  229.             GOSUB DelPT: Z = Z - 1
  230.             C = C + 1: IF INT(C / 10) = C / 10 THEN PRINT ".";
  231.          END IF
  232.       NEXT Z
  233.       PRINT : PRINT "Now removing labels...";
  234.       FOR i = 1 TO nml: REM now eliminate all labels outside
  235.           bad = 0: Xm = MapRng / (60 * Lfac): Ym = MapRng / 60
  236.           IF MLo(i) > LONcen + Xm OR MLa(i) > LATcen + Ym THEN bad = 1
  237.           IF MLo(i) < LONcen - Xm OR MLa(i) < LATcen - Ym THEN bad = 1
  238.           IF bad = 1 THEN
  239.              FOR J = i TO nml
  240.                  ML$(J) = ML$(J + 1): MLa(J) = MLa(J + 1)
  241.                  MLo(J) = MLo(J + 1): MLr(J) = MLr(J + 1)
  242.              NEXT J: nml = nml - 1: PRINT ".";
  243.           END IF
  244.       NEXT i
  245.       GOTO DrawMap
  246.  
  247.  
  248. FindPoint: CurX = INT(.5 + dx + (CUX - 320) / KP)
  249.            CurY = INT(.5 + dy + (CUY - Ycen) / KP)
  250.     GOSUB BoxLine23: PRINT "SEARCHING THROUGH ALL POINTS IN FILE...";
  251.     FOR J = 0 TO 30             ' Go through abt 20 times lookin pt.
  252.         IF J > 10 THEN J = J + 1' first with 0 delta, then bigger
  253.         LNctr = 0: PRINT ".";
  254.         FOR i = 1 TO nmp
  255.             IF x%(i) = 0 THEN LNctr = LNctr + 1
  256.             IF x%(i) > CurX - J AND x%(i) < CurX + J THEN
  257.                IF y%(i) > CurY - J AND y%(i) < CurY + J THEN
  258.                   Z = i: LNptr = LNctr: GOSUB CurToPoint
  259.                   J = 99: i = nmp
  260.                END IF
  261.             END IF
  262.         NEXT i:
  263.     NEXT J
  264.     IF J < 99 THEN PRINT "None found!": RETURN
  265.     GOSUB MapPoint: SavClr = 0: RETURN
  266.                   
  267. NewFeature: LOCATE 24, 1: PRINT SPACE$(27); : GOSUB BoxLine23
  268.             INPUT "Enter reference name for new feature"; a$
  269.             IF a$ = "" THEN RETURN
  270.             LOCATE 25, 1
  271.             FOR i = 0 TO 14
  272.             PRINT RIGHT$(" " + MID$(STR$(i + 1), 2), 2); "   ";
  273.             LINE (16 + i * 40, 335 * YfacTXT)-(40 + i * 40, 349 * YfacTXT), i + 1, BF
  274.             NEXT i
  275.             GOSUB BoxLine23
  276.             INPUT "Select color (4,7,10-Hwys 11-Water 12-Hwy 13-Spcl 14-City)"; B$
  277.             SavClr = VAL(B$): IF SavClr > 15 OR SavClr < 1 THEN RETURN
  278.             x%(nmp) = 0: y%(nmp) = SavClr    'Store feature color 0,c
  279.             LN$(LNi + 1) = LN$(LNi): LNptr = LNi'Bump up present LN$ comment
  280.             LN$(LNi) = a$: LNi = LNi + 1'Store feature name
  281.             nmp = nmp + 1: Z = nmp
  282.             nmp = nmp + 1: x%(nmp) = 0: y%(nmp) = 0'nmp points to ending 0,0
  283.             GOSUB BoxLine23: LOCATE 25, 1: PRINT SPACE$(80); : LOCATE 25, 1
  284.             IF RIGHT$(Key$, 1) = CHR$(48) THEN
  285.                PRINT "NOW USE DIGITIZER TO ADD NEW POINTS TO THIS FEATURE...";
  286.                GOSUB GetXY: GOSUB Cursor
  287.             ELSE
  288.                PRINT "NOW MOVE CURSOR AND USE ALT-A TO ADD POINTS TO THIS NEW FEATURE...";
  289.             END IF
  290.             GOSUB MakePT
  291.             RETURN
  292.             
  293.  
  294. NewCenter: LATcen = CPY: LONcen = CPX: Changed = Changed + 1: GOTO CurDrwMap
  295.  
  296. MapRange: GOSUB BoxLine23: INPUT "Enter map range"; a$
  297.           IF VAL(a$) <> 0 THEN MapRng = VAL(a$)
  298.           Changed = Changed + 1: GOTO DrwMPaCur
  299.  
  300. AddPoint: nmp = nmp + 1: Z = Z + 1
  301.           FOR i = nmp TO Z STEP -1
  302.               x%(i) = x%(i - 1): y%(i) = y%(i - 1)
  303.           NEXT
  304.           GOSUB MakePT
  305.           IF SavClr = 0 THEN GOTO DrawMap
  306.           S = Z - 1: LineColor = SavClr: GOTO DP
  307.  
  308. MakePT: x%(Z) = dx + (CUX - 320) / (KP * Hfac)
  309.         y%(Z) = dy + (CUY - Ycen) / KP
  310.         Changed = Changed + 1
  311.         GOTO MapPoint
  312.  
  313. CurToPoint:
  314.      CPX = CDX - (x%(Z) - dx) / ppdV
  315.      CPY = CDY - (y%(Z) - dy) / (ppdV * Yfactr)
  316.      GOTO Cursor
  317.  
  318. DelPT: GOSUB DelZ
  319.        REM if 1st pt, it stays as 1st pt
  320.  
  321.        IF x%(Z) = 0 THEN Z = Z - 1: REM if end pt, it stays as end
  322.        IF x%(Z + 1) = 0 AND x%(Z - 1) = 0 THEN 'It is LAST point
  323.           GOSUB Kline: LNptr = LNptr - 1       'So Kill Line
  324.           GOSUB DelZ                           'And Kiil it
  325.           Z = Z - 1: GOSUB DelZ: Z = Z - 1     'Kill 0,color
  326.        END IF                                  'and -1 to end point
  327.        RETURN
  328.  
  329. DelZ: nmp = nmp - 1
  330.       FOR i = Z TO nmp
  331.           x%(i) = x%(i + 1): y%(i) = y%(i + 1)
  332.       NEXT: Changed = Changed + 1: RETURN
  333.  
  334. NextLine: IF Z >= nmp - 1 THEN Z = nmp - 1: BEEP: RETURN
  335.           DO UNTIL x%(Z) = 0: Z = Z + 1: LOOP
  336.           IF Z < nmp - 1 THEN Z = Z + 1: LNptr = LNptr + 1
  337.           SavClr = 0: GOTO MapPoint
  338. Previous: DO UNTIL Z = 1 OR x%(Z) = 0: Z = Z - 1: LOOP
  339.           IF Z > 3 THEN Z = Z - 1: LNptr = LNptr - 1
  340.           SavClr = 0: GOTO MapPoint
  341.  
  342. KillF: Bi = Z: Changed = Changed + 1
  343.        DO UNTIL x%(Bi) = 0: Bi = Bi - 1: LOOP: Z = Bi + 1
  344.        REM Stop at Beginning (0) point of the feature to kill
  345.        Ni = Bi + 1' Now scan for next feature
  346.        DO UNTIL x%(Ni) = 0: Ni = Ni + 1: LOOP
  347.        REM now move down rest of array to fill
  348.        DO UNTIL Ni = nmp + 1
  349.            x%(Bi) = x%(Ni): y%(Bi) = y%(Ni)
  350.            Bi = Bi + 1: Ni = Ni + 1
  351.        LOOP
  352.        nmp = nmp - (Ni - Bi): y%(nmp) = 0
  353.        GOSUB Kline
  354.        GOTO DrawMap
  355.      
  356. Kline: FOR i = LNptr TO LNi
  357.            LN$(i) = LN$(i + 1)
  358.            NEXT i
  359.            LNi = LNi - 1
  360.            RETURN
  361.  
  362. MapPoint:
  363.      IF Z < 2 THEN Z = 2: LNptr = 1: BEEP: SavClr = 0
  364.      IF Z > nmp - 1 THEN Z = Z - 1: BEEP: SavClr = 0
  365.      IF x%(Z) = 0 THEN
  366.         IF a$ = "-" THEN
  367.              LNptr = LNptr - 1: Z = Z - 1
  368.         ELSE LNptr = LNptr + 1: Z = Z + 1
  369.         END IF: SavClr = 0
  370.      END IF
  371.      IF LNptr < 0 THEN LNptr = 0
  372.      IF Display$ = "MAP" THEN
  373.           LOCATE 22, 1
  374.           PRINT "Fture#"; LNptr; TAB(12); LEFT$(LN$(LNptr) + "            ", 12);
  375.      END IF
  376. DrwMpPt: IF Display$ <> "MAP" THEN RETURN
  377.      CIRCLE (Xtest, Ytest), 10, 0 'Erase old circle
  378.      Xtest = 320 + KP * (x%(Z) - dx) * Hfac
  379.      Ytest = Ycen + KP * (y%(Z) - dy) * Yfactr
  380.      CIRCLE (Xtest, Ytest), 10, 15
  381.      
  382.      LOCATE 23, 1: PRINT "MapPt#"; Z;
  383.      IF Z > 999 THEN PRINT TAB(13); "val:";  ELSE PRINT TAB(12); "vals:";
  384.      PRINT TAB(17); x%(Z); TAB(23); y%(Z)
  385.      RETURN
  386.  
  387. AddLabel: nml = nml + 1
  388.           MLa(nml) = CPY: MLo(nml) = CPX
  389.           GOSUB BoxLine23: INPUT "Enter Label Name"; a$: ML$(nml) = a$
  390.           GOSUB BoxLine23: INPUT "Begin displaying label at what range?"; a$
  391.           a = VAL(a$): IF a <> 0 THEN MLr(nml) = a:  ELSE MLr(nml) = 2048
  392.           Changed = Changed + 1: GOTO labels
  393.  
  394. BoxLine23: LOCATE 23, 1: PRINT SPACE$(80); : LOCATE 23, 1: RETURN
  395.  
  396. ErrorTrap: fault = ERR: 'Error handling routine
  397.            IF ERR = 57 THEN PRINT "  I/O-error-User-logoff"; : RESUME
  398.            IF ERR = 69 THEN PRINT "  Comm-buffer-overflow"; : RESUME
  399.            IF ERR = 53 THEN PRINT "  file-"; F$; "-not-found": CLOSE : RESUME NEXT
  400.            IF ERR = 62 THEN RESUME NEXT
  401.            IF ERR = 55 THEN RESUME NEXT
  402.            IF ERR = 2 THEN PRINT "SYNTAX-error"
  403.            IF ERR = 70 THEN PRINT " WRITE PROTECTED!...": RESUME NEXT
  404.            RESET
  405.            PRINT : PRINT "Error beyond repair. Number = "; ERR;
  406.            INPUT "Hit RETURN to return to DOS"; a$
  407.            SYSTEM
  408.  
  409. MapDIR: CLS : PRINT "MAP FILES DIRECTORY": PRINT
  410.          PRINT "To display MAP files, please enter the path to your xxxxxxx.MAP files."
  411.          PRINT "For example, the default '\APRS\*.MAP' will show all maps in the APRS"
  412.          PRINT "directory.  Similarly '*.map' will search your present QB directory."
  413.          PRINT "For any other path, enter the full file specification.": PRINT
  414.          F$ = "\aprs\*.map"
  415.          PRINT "Enter Filespec for searching the DIRECTORY ("; F$; ")";
  416.          INPUT a$: IF a$ <> "" THEN F$ = a$
  417.          PRINT : PRINT : FILES F$
  418.          RETURN
  419.  
  420.  
  421. LoadMap: 'Maps are drawn to the default EGA resolution of 640 x 400 (350)
  422. Again: GOSUB BoxLine23
  423.        INPUT " Enter map FILENAME, or NEW, or ? for a list, or Q to quit)"; a$
  424.        IF UCASE$(a$) = "Q" THEN SYSTEM
  425.        IF a$ = "?" THEN GOSUB MapDIR: GOTO Again
  426.        IF UCASE$(a$) = "NEW" THEN GOSUB NewMap: RETURN
  427.        a = INSTR(3, a$, "."): IF a = 0 THEN a$ = a$ + ".map"
  428.        MapFile$ = UCASE$(a$): F$ = MapFile$: OPEN F$ FOR INPUT AS #3
  429.        IF fault = 53 THEN fault = 0: PRINT : CLOSE #3: GOTO Again
  430.        GOSUB BoxLine23: PRINT " Loading "; F$; "..."
  431.        INPUT #3, LATo: LINE INPUT #3, LATtext$
  432.        INPUT #3, LONo: LINE INPUT #3, LONtext$
  433.        INPUT #3, ppdV: LINE INPUT #3, VS$'Pixels per degree horiz
  434.        INPUT #3, LATcen: LINE INPUT #3, LATcen$
  435.        INPUT #3, LONcen: LINE INPUT #3, LONcen$
  436.        INPUT #3, MapRng: LINE INPUT #3, MapRng$
  437.        INPUT #3, MinRng: LINE INPUT #3, MR$
  438.        LINE INPUT #3, TextLine$ ' Line of comments or instrutcitons
  439.        RS = 2 ^ INT(LOG(MapRng) / LOG(2))'Rng is intgr of VERTrng
  440.        i = 0: LNi = 0:
  441.      
  442.      DO WHILE NOT EOF(3)
  443.         i = i + 1: INPUT #3, x%(i), y: y%(i) = y * Yfactr
  444.         IF x%(i) = 0 AND NOT EOF(3) THEN ' Get line color & store with x=0
  445.            INPUT #3, y%(i): LNi = LNi + 1: LINE INPUT #3, LN$(LNi)' Save line name
  446.            IF y = -1 THEN GOSUB LoadLabels ' All labels listed at end of file
  447.            END IF
  448.         LOOP: nmp = i  'nmp points to 0,-1 that ends all data (but the value
  449.                        'of X% and y% are 0,0 until file is saved.
  450.      LET CDY = LATcen: CDX = LONcen'Center display on ORIGIN
  451.      LET CPX = CDX: CPY = CDY 'Cursor Posn to Center of Display
  452.      LET Z = 2: LNptr = 1: REM start at first point and first line segment
  453.      CLOSE #3: RETURN:     REM first X% value is map color.  2nd val is 1st pt
  454.  
  455.  
  456.  
  457. LoadLabels: K = 0
  458.      DO WHILE NOT EOF(3)
  459.         K = K + 1: INPUT #3, ML$(K), MLa(K), MLo(K), MLr(K)
  460.      LOOP
  461.      IF MLa(K) = 0 OR MLo(K) = 0 THEN nml = K - 1 ELSE nml = K
  462.      RETURN
  463.        
  464. SaveMap: GOSUB BoxLine23
  465.    PRINT "Enter file name to save if other than "; MapFile$;
  466.    INPUT a$: IF a$ <> "" THEN MapFile$ = a$
  467.    F$ = MapFile$
  468.    GOSUB BoxLine23: PRINT "Saving map to file named "; F$; " ..."
  469.    OPEN F$ FOR OUTPUT AS #4
  470.    IF fault = 70 THEN CLOSE #4: GOTO SaveMap
  471.    PRINT #4, LATo; ","; LATtext$
  472.    PRINT #4, LONo; ","; LONtext$
  473.    PRINT #4, ppdV; ","; VS$
  474.    PRINT #4, LATcen; ","; LATcen$
  475.    PRINT #4, LONcen; ","; LONcen$
  476.    PRINT #4, MapRng; ","; MapRng$
  477.    PRINT #4, MinRng; ","; MR$
  478.    PRINT #4, TextLine$
  479.    J = 1
  480.    FOR i = 1 TO nmp
  481.        IF x%(i) <> 0 THEN WRITE #4, x%(i), INT((y%(i) / Yfactr) + .5)
  482.        IF x%(i) = 0 AND i = nmp THEN PRINT #4, " 0,-1"
  483.        IF x%(i) = 0 AND i <> nmp THEN
  484.           PRINT #4, "0,0"
  485.           PRINT #4, y%(i); ","; LN$(J): J = J + 1
  486.        END IF
  487.    NEXT i
  488.    PRINT #4, "0,"; LN$(LNi)
  489.    FOR K = 1 TO nml
  490.        PRINT #4, ML$(K); ","; : WRITE #4, MLa(K), MLo(K), MLr(K)
  491.    NEXT K: CLOSE #4: LOCATE 24, 1:
  492.    Changed = 0
  493.    IF nmp > MaxNumPoints OR nml > MaxNumLABELS THEN
  494.       CLS : LOCATE 9, 29: PRINT "CAUTION!": PRINT : PRINT
  495.       IF nmp > MaxNumPoints THEN
  496.          PRINT "            The number of points is greater than"; MaxNumPoints
  497.       END IF
  498.       IF nml > MaxNumLABELS THEN
  499.          PRINT "            The number of LABELS is greater than"; MaxNumLABELS
  500.       END IF
  501.       LOCATE 18, 12
  502.       PRINT " Therefore this map will not work with APRS (yet) "
  503.       LOCATE 23, 1: INPUT "HIT Enter to continue..."; a$
  504.    END IF: GOTO DrwMPaCur
  505.  
  506. CurDrwMap: CDX = CPX: CDY = CPY: GOTO DrawMap: REM Re-center at CURSOR location
  507.  
  508. DrwMPaCur: CPX = CDX: CPY = CDY: GOSUB DrawMap
  509.            REM After drawing map, Put cursor at center
  510.            RETURN
  511.  
  512. DrawMap: Display$ = "MAP": COLOR 15, 0
  513.    'Draw to range scale RS and center display CDX and CDY
  514.    'Original Map was 40 pix-per-deg Horiz and 20 vert for 200 display
  515.    'Now ppdH and ppdV are variables.  The scaling factor KP is 1 for
  516.    'the original map scale.
  517.    IF RS < MinRng THEN LET RS = MinRng
  518.    IF RS > 8192 THEN RS = 8192
  519.    KP = 100 * 100 / (RS * ppdV)'This is to scale it down from the 120 maps
  520.    Sfac = 50 * 200 / RS        'Till 307 had been 100*120
  521.  
  522.    Lfac = COS(CDY / 57.296)
  523.    Hfac = (640 / 350) * (3 / 4) * Lfac
  524.    dx = ppdV * (LONo - CDX)
  525.    dy = ppdV * (LATo - CDY)
  526.         
  527.    CLS : LOCATE 1, 2: PRINT "Redrawing Map"
  528.    REM first put ORIGIN and map CENTER on the map
  529.    LINE (320 - KP * dx, Ycen - KP * dy)-(960 - KP * dx, Ycen - KP * dy), 14
  530.    LINE (320 - KP * dx, Ycen - KP * dy)-(320 - KP * dx, 3 * Ycen - KP * dy), 14
  531.    CMX = 320 + Sfac * (CDX - LONcen) * Hfac'new
  532.    CMY = Ycen + Sfac * (CDY - LATcen) * Yfactr
  533.    LINE (CMX - 27, CMY)-(CMX + 27, CMY), 14
  534.    LINE (CMX, CMY - 20)-(CMX, CMY + 20), 14
  535.    CIRCLE (CMX, CMY), 10, 14
  536.    CIRCLE (320 - KP * dx, Ycen - KP * dy), 12, 14
  537.    S = 0: GOSUB MapPoint: REM Redraw MapPoint
  538. DP: FOR i = S TO nmp - 1
  539.        x = 320 + KP * (x%(i) - dx) * Hfac
  540.        y = Ycen + KP * (y%(i) - dy) * Yfactr
  541.        X1 = 320 + KP * (x%(i + 1) - dx) * Hfac
  542.        Y1 = Ycen + KP * (y%(i + 1) - dy) * Yfactr
  543.        IF x%(i + 1) <> 0 THEN
  544.           IF RdsOn OR LineColor <> 12 THEN LINE (x, y)-(X1, Y1), LineColor
  545.           IF i = Z THEN SavClr = LineColor
  546.        ELSE
  547.           LineColor = y%(i + 1): i = i + 1
  548.           IF Display$ = "SHOW" AND LineColor > 8 THEN LineColor = LineColor - 8
  549.        END IF
  550.    NEXT i
  551.    GOSUB Cursor
  552.    REM MapPoint went here
  553.    GOSUB DrawHist: REM draw GPS history track
  554.    IF Display$ = "SHOW" THEN
  555.       GOSUB ShowMaps
  556.    ELSE
  557.       LOCATE 25, 1: PRINT "Use +/- to move MAPpoint.  N/P for Next/Previous Feature.  H for HELP!.";
  558.       LOCATE 1, 61
  559.       PRINT "POINTS"; nmp; "= "; INT((nmp / MaxNumPoints) * 100); "%";
  560.       LOCATE 2, 61
  561.       PRINT "LABELS "; nml; "= "; INT((nml / MaxNumLABELS) * 100); "%";
  562.       LOCATE 3, 61: PRINT "CENTER  "; MID$(STR$(LATcen), 2, 5);
  563.       LOCATE 3, 75: PRINT MID$(STR$(LONcen), 2, 5)
  564.       LOCATE 4, 61: PRINT "SCALE   (ppd)"; ppdV
  565.       LOCATE 5, 69: PRINT "Range"; LEFT$(STR$(MapRng), 5)
  566.    END IF
  567.  
  568. labels:
  569.    IF Labls THEN
  570.       FOR i = 1 TO nml ' Now plot labels on map
  571.       IF RS <= MLr(i) OR Key$ = "S" THEN
  572.          LET x = 320 + Sfac * (CDX - MLo(i)) * Hfac'new
  573.          LET y = Ycen + Sfac * (CDY - MLa(i)) * Yfactr
  574.          IF Tags AND y > 14 * Yfactr AND y < 350 * Yfactr AND x > 8 * (LEN(ML$(i)) + 1) AND x < 632 THEN
  575.             LOCATE y / (14 * Yfactr), (x / 8) - LEN(ML$(i)): PRINT ML$(i);
  576.             END IF
  577.          END IF
  578.       NEXT i
  579.    END IF
  580.    GOSUB ShowMap: RETURN
  581.          
  582. ShowMap: REM this shows the map boarder of the loaded map
  583.     x = 320 + KP * (CDX - LONcen) * ppdV * Hfac'new
  584.     y = Ycen + KP * (CDY - LATcen) * ppdV * Yfactr
  585.       by = MapRng * Sfac * Yfactr / 60
  586.       bx = by * 640 / (400 * Yfactr) * Lfac'old
  587.       C = 15
  588.     LINE (x - bx, y - by)-(x + bx, y + by), C, B
  589.     RETURN
  590.  
  591. Cursor: CIRCLE (CUX, CUY), 4, 0
  592.      CUX = 320 + Sfac * (CDX - CPX) * Hfac'new
  593.      CUY = Ycen + Sfac * (CDY - CPY) * Yfactr
  594.      CIRCLE (CUX, CUY), 4, 14
  595.      x = INT(CPX): y = INT(CPY): Xm = (CPX - x) * 60: Ym = (CPY - y) * 60
  596.      x$ = RIGHT$(STR$(x), 3) + " "
  597.      LOCATE 1, 2: PRINT "RNG"; RIGHT$("   " + STR$(RS), 4) + "      "
  598.      LOCATE 2, 2: PRINT "LAT "; y; MID$(STR$(Ym) + "   ", 2, 5)
  599.      LOCATE 3, 2: PRINT "LON "; x$; MID$(STR$(Xm) + "   ", 2, 5)
  600.     
  601.      LOCATE 24, 1: PRINT "Cursor coordnts:"; TAB(17);
  602.      PRINT INT(.5 + dx + (CUX - 320) / KP); TAB(23); INT(.5 + dy + (CUY - Ycen) / KP);
  603.      REM LOCATE 24, 55: PRINT "Degrees: ";
  604.      REM PRINT LEFT$(STR$(CPY) + " ", 7); LEFT$(STR$(CPX) + "   ", 7);
  605.      LOCATE 1, 16: PRINT "Decimal";
  606.      LOCATE 2, 15: PRINT LEFT$(STR$(CPY) + " ", 8);
  607.      LOCATE 3, 15: PRINT LEFT$(STR$(CPX) + "   ", 8);
  608.      LINE (0, 0)-(178, 42 * Yfactr), 12, B'Box around it
  609.      LINE (0, 0)-(116, 42 * Yfactr), 12, B'Box around it
  610.      LET a$ = "": LET B$ = "": RETURN
  611.  
  612. HELP: CLS : COLOR 15, 1: LINE (0, 0)-(639, 18 * Yfactr), 14, BF
  613.       LOCATE 1, 20: PRINT " MAPFIX.bas HELP SCREEN Ver "; Ver$
  614.       LOCATE 3, 1
  615.       
  616.       PRINT " The cursor is shown in LAT/LON, map offset and decimal degrees.   The ORIGIN,"
  617.       PRINT " CENTER and BORDER are shown (but only the CENTER and RANGE in MAPLIST.map are"
  618.       PRINT " actually used by APRS.  Labels are right justified to the point just after the"
  619.       PRINT " last letter.  CALLS & OBJECT names will be left justified."
  620.       PRINT ""
  621.       PRINT " H - HELP screen  D - DIRECTRY of maps  alt-A Add point    alt-L LABEL placemnt"
  622.       PRINT " G - GOTO map-pnt F - FIND PT @ Cursor  alt-B BEGIN dgtzr  alt-M MOVE point"
  623.       PRINT " L - LABELS off   S - SHOW all labels   alt-C CENTER point alt-N NEW feature"
  624.       PRINT " M - MAPLIST.map  O - OTHER map borders alt-D DELETE point alt-O OPEN Dgtzr COM"
  625.       PRINT " N - NEXT Feature R - RESET pointers    alt-G GPS overlay  alt-R RANGE"
  626.       PRINT " P - PREV Feature Q - QUIT  ^S - SAVE!  alt-K KILL feature alt-T TRIM Border pts"
  627.       PRINT
  628.       PRINT " On the MAP screen, use the white arrow keys with NumLock off for best movement"
  629.       PRINT " Space bar        -  Draw map"
  630.       PRINT " Arrow Keys       -  Move cursor. (use Shift with NumLock off to move faster)"
  631.       PRINT " Home (Shift)     -  Home the map to cursor  (Shift-Home the map to ORIGIN)"
  632.       PRINT " PgUp, PgDn       -  Change map scale up/dn by 2 (use CTRL for factor of 8)"
  633.       PRINT " End              -  Redraw map centered on CENTER"
  634.       PRINT " Gray +/- keys    -  Move MapPoint to next point within Feature"
  635.       PRINT
  636.       IF Display$ <> "HELP" THEN
  637.        LOCATE 25, 1
  638.        PRINT " HIT H AGAIN FOR MORE HELP SCREENS, OR SPACE BAR FOR MAP...";
  639.       END IF
  640.       Display$ = "HELP"
  641.       LINE (0, 0)-(634, 348 * Yfactr), 15, B
  642.       RETURN
  643.  
  644.  
  645.  
  646. REM ************* HERE IS THE CODE BROUGHT IN FROM APRS  ***************
  647.  
  648. LdMapLst: MapListLoaded = -1
  649.           F$ = "Maplist.map": OPEN F$ FOR INPUT AS #3
  650.           i = 1: IF fault = 53 THEN STOP
  651.           INPUT #3, DfltY: LINE INPUT #3, a$
  652.           INPUT #3, DfltX: LINE INPUT #3, a$
  653.           INPUT #3, BestRng: LINE INPUT #3, a$: DfltR = BestRng
  654.           INPUT #3, GMToffset: LINE INPUT #3, a$
  655.     WHILE a$ <> "* BEGIN *": LINE INPUT #3, a$: WEND ' Skip comment block
  656.           REM RS = BestRng: REM center display
  657.           REM RS = 2 ^ INT(LOG(RS) / LOG(2))'Rng is intgr power of 2
  658.           REM CPX = CDX: CPY = CDY 'Cursor Posn to Center of Display
  659.     WHILE NOT EOF(3) AND i <= UBOUND(MapName$)
  660.           INPUT #3, MapName$(i), LATcen(i), LONcen(i), MapMax(i)
  661.           LINE INPUT #3, Comment$(i)' IGNORE ALL comment fields
  662.           REM now ignore maps that start with a *
  663.           IF LEFT$(MapName$(i), 1) <> "*" THEN NumGood = NumGood + 1
  664.           NumMaps = i: i = i + 1
  665.     WEND: CLOSE #3
  666.     IF NumGood >= MaxNumMAPS - 1 THEN
  667.           CLS : LOCATE 2, 5
  668.           PRINT "WARNING: Too many ACTIVE MAPS (more than"; MaxNumMAPS; ") in MAPLIST.map file for APRS"
  669.           LOCATE 4, 10: PRINT "Use EDITOR to suppress mapnames with an (*) that you don't need."
  670.           PRINT : PRINT : PRINT
  671.           INPUT "HIT RETURN to continue"; a$
  672.     END IF
  673.     RETURN
  674.  
  675. ListMAPlist: IF NOT MapListLoaded THEN GOSUB LdMapLst
  676.    GOSUB ListHeader
  677.    FOR i = 1 TO NumMaps
  678.        IF i / 19 = INT(i / 19) THEN
  679.           LOCATE 25, 1: PRINT "HIT RETURN to continue"; : INPUT a$
  680.           GOSUB ListHeader
  681.        END IF
  682.        PRINT MapName$(i); TAB(14);
  683.        PRINT INT(LATcen(i) * 100) / 100; TAB(21); INT(LONcen(i) * 100) / 100;
  684.        PRINT TAB(29); MapMax(i); TAB(36); LEFT$(Comment$(i), 43)
  685.    NEXT i
  686.    
  687.    LOCATE 25, 1: PRINT "LIST COMPLETE. CONTINUE WITH NEXT MAPFIX COMMAND...";
  688.    RETURN
  689.  
  690. ListHeader: CLS
  691.    PRINT "MAPS in MAPLIST.map (*MAPS are suppressed)     [For now, use EDITOR to modify]"
  692.    PRINT :
  693.    PRINT "MAP NAME      LATcen LONcen  RANGE COmments"
  694.    PRINT "------------  ------ ------- ----- -------------------------------------------"
  695.    RETURN
  696.  
  697. DrwAndShow: IF NOT MapListLoaded THEN GOSUB LdMapLst
  698.             Display$ = "SHOW": GOSUB DrwMPaCur
  699.  
  700. ShowMaps: IF MapSize > RS / 2 THEN MapSize = RS / 2
  701.     LOCATE 25, 1: PRINT " Drawing all maps >"; MapSize;
  702.     PRINT "mi.  F3 to see smaller, F4 for bigger, SPACE to cancel.";
  703.     LINE (0, 336 * Yfactr)-(639, 349 * Yfactr), 14, B
  704.     FOR i = 1 TO NumMaps
  705.    
  706.     x = 320 + Sfac * (CDX - LONcen(i)) * Hfac
  707.     y = Ycen + Sfac * (CDY - LATcen(i)) * Yfactr
  708.       dy = MapMax(i) * Sfac * Yfactr / 60
  709.       dx = dy * 640 / (400 * Yfactr) * Lfac
  710.       C = 15
  711.       IF MapMax(i) > 32 THEN C = 14
  712.       IF MapMax(i) > 64 THEN C = 12
  713.       IF MapMax(i) > 128 THEN C = 11
  714.       IF MapMax(i) > 256 THEN C = 13
  715.           
  716.     IF MapMax(i) > MapSize THEN
  717.        LINE (x - dx, y - dy)-(x + dx, y + dy), C, B
  718.        IF y + dy > 14 * Yfactr AND y + dy < 350 * Yfactr THEN
  719.           IF x + dx > 8 * (LEN(MapName$(i)) + 1) AND x + dx < 632 THEN
  720.              LOCATE (y + dy) / (14 * Yfactr), (x + dx) / 8 - LEN(MapName$(i))
  721.              IF MapMax(i) > RS / 4 THEN PRINT MapName$(i);
  722.           END IF
  723.        END IF
  724.     END IF
  725.     NEXT i: RETURN
  726.         
  727. REM ******* here is the code added by W7KKE for overlyaying track histoiries
  728. 'This module retrieves GPS history files so you can check the accuracy of
  729. 'the map
  730.  
  731. Hstdir: CLS : PRINT "HISTORY FILES DIRECTORY": PRINT
  732.          PRINT "To display HST files, please enter the path to your xxxxxxx.HST files."
  733.          PRINT "For example, the default '\APRS\*.HST' will show all maps in the APRS"
  734.          PRINT "directory.  Similarly '*.hst' will search your present QBasic directory."
  735.          PRINT "For any other path, enter the full file specification.": PRINT
  736.          
  737.          PRINT "Enter Filespec for searching the DIRECTORY (\aprs\*.hst)";
  738.          INPUT F$: IF F$ = "" THEN F$ = "\aprs\*.hst"
  739.          IF INSTR(F$, ".") = 0 THEN F$ = F$ + ".HST"
  740.          PRINT : PRINT : FILES F$
  741.          RETURN
  742.  
  743. LoadHst: GOSUB BoxLine23
  744.        INPUT "Which history file to load (ENTER for list, Q to quit)"; F$
  745.        IF UCASE$(F$) = "Q" THEN RETURN
  746.        IF F$ = "" THEN GOSUB Hstdir: GOTO LoadHst
  747.        a = INSTR(3, F$, "."): IF a = 0 THEN F$ = F$ + ".hst"
  748.        fault = 0: F$ = UCASE$(F$): OPEN F$ FOR INPUT AS #3
  749.    
  750.        IF fault = 53 OR fault = 62 THEN fault = 0: RETURN
  751.        GOSUB BoxLine23: PRINT "Loading track history from "; F$
  752.        
  753.     DO WHILE NOT EOF(3)
  754.        i = i + 1
  755.        INPUT #3, a$
  756.        HLAT(i) = VAL(MID$(a$, 26, 2)) + (VAL(MID$(a$, 28, 5)) / 60)
  757.        HLONG(i) = VAL(MID$(a$, 35, 3)) + (VAL(MID$(a$, 38, 5)) / 60)
  758.        maxhist = i
  759.      LOOP
  760.      CLOSE #3: Histloaded = -1
  761.      GOSUB BoxLine23: PRINT "File loading is complete.  GPS data is plotted."
  762.      REM fall through...
  763.  
  764. DrawHist:  'put history track on map
  765.      IF Histloaded THEN
  766.         size = 3: IF RS < 2 THEN size = size * 2 / RS
  767.         FOR i = 1 TO maxhist
  768.             HMX = 320 + KP * (CDX - HLONG(i)) * ppdV * Hfac'new
  769.             HMY = Ycen + KP * (CDY - HLAT(i)) * ppdV * Yfactr
  770.             CIRCLE (HMX, HMY), size, 13
  771.         NEXT i
  772.      END IF
  773.      RETURN
  774.  
  775. NewMap: CLS : PRINT "BEGINNING A NEW MAP FROM SCRATCH...": PRINT
  776.    PRINT "All points in an APRS map are measured as an"
  777.    PRINT "offset to the right and down from an origin."
  778.    PRINT
  779.    INPUT "Enter the LATITUDE  of the ORIGIN in decimal degrees"; LATo
  780.    INPUT "Enter the LONGITUDE of the ORIGIN in decimal degrees"; LONo
  781.    PRINT
  782.    PRINT "Choose the number of pixels per degree to set the map scale:"
  783.    PRINT
  784.    PRINT "Approximate size    Range from center  Pixels/Deg"
  785.    PRINT "----------------    -----------------  ----------"
  786.    PRINT "Big state or region        500             120"
  787.    PRINT "Typical state              200             300"
  788.    PRINT "Several Counties           100             600"
  789.    PRINT "Typical VHF range           50            1200"
  790.    PRINT "City streets (7.5 min maps) 25            2400"
  791.    PRINT
  792.    INPUT "Enter desired Pixels/Deg"; ppdV
  793.    IF ppdV = 0 THEN GOTO NewMap
  794.    REM In following lines, 500 is half of 999 (maximum nominal value for pts)
  795.    LATcen = LATo - (500 * Yfactr / ppdV): LATcen$ = "LAT of ORIGIN"
  796.    LONcen = LONo - (500 / ppdV): LONcen$ = "LON of Origin"
  797.    MapRng = 60 * 500 * Yfactr / ppdV: REM 500 is half of full map size
  798.    MapRng$ = "Map range from center"
  799.    VS$ = "Pixels per degree"
  800.    MinRng = 1: MR$ = "No longer used"
  801.    TextLine$ = "NEW Map generated by MAPFIX.bas routine..."
  802.    RS = 2 ^ INT(LOG(MapRng) / LOG(2))'Rng is intgr of VERTrng
  803.    CDX = LONcen: CDY = LATcen: CPX = CDX: CPY = CDY
  804.    nmp = 1
  805.    LNi = 1: LN$(1) = "Labels begin here"
  806.    CLS : PRINT "YOU ARE NOW READY TO DRAW A NEW MAP...": PRINT : PRINT
  807.    PRINT "A white border has been drawn around the maximum size permitted for this map"
  808.    PRINT
  809.    PRINT "USING CURSOR WITHOUT DIGITIZER:  Move coursor to starting point for a NEW"
  810.    PRINT "feature and hit ALT-N.  Then enter new feature name (for reference purposes)"
  811.    PRINT "and continue moving cursor to the next point and hit ALT-A to add more points."
  812.    PRINT "Continue in this fashion, using ALT-N whenever you want to begin a NEW feature."
  813.    PRINT
  814.    PRINT "USING A DIGITIZER:  First, use ALT-O once to OPEN the digitizer COM port.  Then"
  815.    PRINT "use ALT-B to BEGIN each new map feature.  Enter the name and color of the new"
  816.    PRINT "feature.  Then use the digitizer mouse to add more points."
  817.    PRINT : PRINT : PRINT
  818.    PRINT "Add LABELS on the map at the current cursor location by using the ALT-L key. "
  819.    PRINT
  820.    PRINT "When you are finished, be sure to SAVE the map using the CTRL-S command..."
  821.    PRINT : PRINT : PRINT
  822.    PRINT "FOR HELP, REMEMBER THE  H  KEY!"
  823.    PRINT : PRINT : PRINT "Hit ENTER to proceed..."; : INPUT a$
  824.    RETURN
  825.  
  826. DigiInit: CLS : PRINT : Digitizer = -1
  827.    PRINT "This routine will replace many CURSOR functions with the Digitizer's MOUSE."
  828.    PRINT "Assuming your digitizer can output an X,Y,C format."
  829.    PRINT
  830.    PRINT "Only Mercator projection charts will give absolutely accurate results.  Other"
  831.    PRINT "types, Lambert Conformal, Conical, etc will induce distortions."
  832.    PRINT
  833.    PRINT "It has not been tested with East Longitude or South Latitude."
  834.    PRINT : PRINT
  835.    PRINT "The digitizr should operate at 9600,N,8,1 in POINT mode with 200 LPI resolution."
  836.    PRINT "The FORMAT outputs X,Y,C values separated by commas (C is for button pressed."
  837.    PRINT
  838.    PRINT "Set up the digitizer according to your model's instructions.  For the model"
  839.    PRINT "23360, use the drawing board menu by pressing the mouse button 0 on the SETUP"
  840.    PRINT "label so that the LED is ON.  Then move the mouse to each other label and"
  841.    PRINT "use the 0 button to toggle the value ON or off as follows:"
  842.    PRINT
  843.    PRINT "POINT is ON                             PARITY 7/8 and 1 are ON "
  844.    PRINT "BAUDRATE 3 is ON                        FORMAT is ON ON off ON"
  845.    PRINT "DATA RATE doesn't matter                RESOLUTION off off ON"
  846.    PRINT : PRINT
  847.    INPUT "Is DIGITIZER connected to COM1 or COM2 (1)"; a$
  848.    IF a$ <> "2" THEN a$ = "COM1" ELSE a$ = "COM2"
  849.  
  850.    Port$ = a$ + ":9600,N,8,1,cs0,ds0,cd0"
  851.    OPEN Port$ FOR RANDOM AS #1
  852.    
  853.  
  854.    CLS : PRINT "FIRST LETS TEST THE DIGITIZER, AND GET THE MAP ON STRAIGHT.": PRINT
  855.    PRINT "Move your mouse (or pen) and hit the 0 button (or touch tablet) to see if the"
  856.    PRINT "digitizer is outputting in the desired format.  While doing this, it is a good"
  857.    PRINT "idea to verify that your map is on straight.  The Y values from the mouse"
  858.    PRINT "should give the same values for the same LATITUDE line on both the right and"
  859.    PRINT "left edges of the map.  If not, move your map to get it horizontal."
  860.    PRINT
  861.    PRINT "OUTPUT FORMAT:"
  862.    PRINT
  863.    PRINT "XXXXX,YYYYY,APn (Only the X and Y values are used (4 or 5 digits is ok)"
  864.    PRINT
  865.    LOCATE 25, 1: PRINT "Hit ENTER and press 0 button on mouse to continue...";
  866.    LOCATE 13, 1
  867.    DO UNTIL INKEY$ <> "": LINE INPUT #1, a$: PRINT a$: LOOP
  868.   
  869.    CLS : PRINT
  870.    PRINT "NEXT YOU MUST ESTABLISH THE SCALE OF YOUR DIGITIZER."
  871.    PRINT
  872.    PRINT "The scale is established by two points, the first near the"
  873.    PRINT "upper left corner, the second near the lower right corner."
  874.    PRINT
  875.    PRINT "To get the best accuracy on maps not exactly MERCATOR, use points within the "
  876.    PRINT "area where you are working, not on the extreme corners.  IE:  choose points"
  877.    PRINT "that are in the center of the upper left quadrant and the lower right quadrant."
  878.    PRINT
  879.    PRINT "To establish the upper left reference point:"
  880.    INPUT "     Enter lat  (deg,min)"; LATref1, M: LATref1 = LATref1 + M / 60
  881.    INPUT "     Enter long (deg,min)"; LONref1, M: LONref1 = LONref1 + M / 60
  882.    PRINT
  883.  
  884.    PRINT "Place the mouse on the upper left point and press the 0 button."
  885.    LINE INPUT #1, a$: SOUND 150, 3
  886.         digix1 = 5000 - VAL(LEFT$(a$, 5))
  887.         digiy1 = VAL(MID$(a$, 7, 5))
  888.         PRINT "Digitizer reads "; digix1, digiy1; " for this point.": PRINT
  889.  
  890.    PRINT "NOW Establish the lower right reference point:"
  891.    INPUT "      Enter lat  (deg,min)"; LATref2, M: LATref2 = LATref2 + M / 60
  892.    INPUT "      Enter long (deg,min)"; LONref2, M: LONref2 = LONref2 + M / 60
  893.    PRINT
  894.    PRINT "Place digitizer pen on lower right point."
  895.    LINE INPUT #1, a$: SOUND 150, 3
  896.         digix2 = 5000 - VAL(LEFT$(a$, 5))
  897.         digiy2 = VAL(MID$(a$, 7, 5))
  898.         PRINT "Digitizer reads "; digix2, digiy2; " for this point.": PRINT
  899.  
  900.    REM Find delta lat/long between reference points
  901.    REM Calculate degrees per x/y unit
  902.         degx# = (LONref1 - LONref2) / (digix1 - digix2)
  903.         degy# = (LATref1 - LATref2) / (digiy1 - digiy2)
  904.  
  905.    CLS : PRINT "YOU ARE NOW READY TO USE THE DIGITIZER TO ENTER POINTS INTO MAPFIX..."
  906.    PRINT
  907.    PRINT "The digitizer works just about like the cursor and arrow keys in MAPFIX.  Any"
  908.    PRINT "point identified by the digitizer will be ADDED just as if you had hit ALT-A."
  909.    PRINT "All points are added to a feature after the current MapPoint identified by the"
  910.    PRINT "white circle. "
  911.    PRINT
  912.    PRINT "With the digitizer, do NOT use the ALT-N NEW command which always begins at the"
  913.    PRINT "current cursor location.  For the digitizer, use ALT-B to BEGIN a new feature."
  914.    PRINT "You will be asked to identify the name and color of the new feature.  From then"
  915.    PRINT "on, just move the digitizer mouse (or pen) to ADD new points.  "
  916.    PRINT
  917.    PRINT "If your digitizer mouse has 4 buttons, use the first (left) button for ADDing "
  918.    PRINT "points, use the 4th (right) button to just move the cursor with no action."
  919.    PRINT : PRINT
  920.    INPUT "Hit ENTER to continue with MAPFIX..."; a$
  921.    RETURN
  922.  
  923. GetXY: LINE INPUT #1, a$: SOUND 150, 3
  924.        a = INSTR(a$, ","): IF a = 0 THEN RETURN
  925.            x = 5000 - VAL(LEFT$(a$, a - 1))
  926.        B = INSTR(a + 1, a$, ","): IF B = 0 THEN B = LEN(a$)
  927.        y = VAL(MID$(a$, a + 1, B - (a)))
  928.        Btn = VAL(RIGHT$(a$, 1))
  929.        CPY = ((y - digiy2) * degy#) + LATref2
  930.        CPX = ((x - digix2) * degx#) + LONref2
  931.        IF LOC(1) <> 0 THEN a$ = INPUT$(LOC(1), #1)'Clear input buffer
  932.        RETURN
  933.  
  934. END
  935.  
  936.